def demo(my_str, num, num_list, num_tuple, num_dict, num_set):
    """
    对于非可变类型数据(int,float,str)，函数内部的修改影响不到调用函数时传入的实参
    对于可变类型数据(list,dict,set)，函数内部的修改可以影响到调用函数时传入的实参
    注意：元组tuple影响不到,
    测试发现：传入int,str,tuple时，形参和实参的地址不同，所以函数内部的修改影响不到调用函数时传入的实参
            传入list,dict,set时，形参和实参的地址相同，所以函数内部的修改可以影响调用函数时传入的实参
    """
    print("函数内部代码")
    my_str += "def"
    num += num
    num_list += [4, 5, 6]
    num_tuple += (4, 5, 6)
    print(f"元组地址{id(num_tuple)}")
    new_dict = {4: "four", 5: "five", 6: "six"}
    num_dict.update(new_dict)
    new_set={4, 5, 6}
    num_set.update(new_set)

    print(my_str)
    print(id(my_str))
    print(num)
    print(id(num))
    print(num_list)
    print(id(num_list))
    print(num_tuple)
    print(id(num_tuple))
    print(num_dict)
    print(id(num_dict))
    print(num_set)
    print(id(num_set))
    print("函数代码完成")

def test_func(num_tuple):
    """
    测试元组在函数中进行扩展是否可以影响到传入的实参
    答案是：不能
    :param num_tuple:
    :return:
    """
    print(num_tuple)
    num_tuple+=(4,5,6)
    print(num_tuple)


if __name__ == '__main__':
    gl_str = "abc"
    gl_num = 10
    gl_list = [1, 2, 3]
    gl_tuple = (1, 2, 3)
    gl_dict = {1: "one", 2: "two", 3: "three"}
    gl_set = {1, 2, 3}
    demo(gl_str, gl_num, gl_list, gl_tuple, gl_dict, gl_set)

    print(gl_str)
    print(id(gl_str))
    print(gl_num)
    print(id(gl_num))
    print(gl_list)
    print(id(gl_list))
    print(gl_tuple)
    print(id(gl_tuple))
    print(gl_dict)
    print(id(gl_dict))
    print(gl_set)
    print(id(gl_set))

    # test_tuple=(1,2,3)
    # test_func(test_tuple)
    # print(test_tuple)
